<?php

namespace App\Requests\Admin\GoodsClass;


use App\Enums\GoodsClassStatusEnum;
use App\Requests\BaseRequest;
use App\Traits\ValidatorTrait;
use Illuminate\Validation\Rule;

class GoodsClassSaveRequest extends BaseRequest
{
    use ValidatorTrait;

    /**
     * 字段注解
     *
     * @return array
     */
    public function attributes(): array
    {
        return [
            'id' => 'ID',
            'sort' => '排序',
            'name' => '名称',
            'pid' => '上级id',
            'image' => '图片',
            'status' => '状态',
            'remark' => '备注',
        ];
    }

    public function rules(): array
    {
        return [
            'id' => ['sometimes', 'integer'],
            'pid' => ['sometimes', 'integer'],
            'sort' => ['sometimes', 'integer'],
            'image' => ['sometimes'],
            'name' => ['required', 'string'],
            'status' => ['sometimes', Rule::in(GoodsClassStatusEnum::getKeyList()),],
            'remark' => ['sometimes', 'nullable', 'string'],
        ];
    }
}
